package com.example.vv.frameWork.mvp;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;

import com.example.vv.frameWork.base.BaseFragment;
import com.example.vv.frameWork.base.BaseView;

import butterknife.ButterKnife;

public abstract class MvpFragment<V extends BaseView,P extends MvpPresenter> extends BaseFragment {
    protected P presenter;
    public FragmentActivity mActivity;

    public abstract int initLayout();
   public abstract P initPresenter();
    public abstract void initView();
    public abstract  void initData();
    public abstract void doBusiness();
    public abstract View titleBar();
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(initLayout(), container, false);
        mActivity = getActivity();
        setBarColor(titleBar());
        presenter=initPresenter();
        presenter.attach((V)this);
        ButterKnife.bind(this,view);
        initData();
        initView();
        doBusiness();
        return view;
    }
}
